package com.westar.base.emum;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum PublicServiceEnum {
    POWER("power","权利事项"),
    SERVICE("service","公共服务");

    // 成员变量
    private String describe;
    private String param;


    PublicServiceEnum(String param, String describe) {
        this.param = param;
        this.describe = describe;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public static PublicServiceEnum getEnum(String param) {
        PublicServiceEnum resultEnum = null;
        PublicServiceEnum[] enumAry = PublicServiceEnum.values();
        for (int i = 0; i < enumAry.length; i++) {
            if (enumAry[i].getParam().equals(param)) {
                resultEnum = enumAry[i];
                break;
            }
        }
        return resultEnum;
    }

    public static Map<String, Map<String, Object>> toMap() {
        PublicServiceEnum[] ary = PublicServiceEnum.values();
        Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
        for (int num = 0; num < ary.length; num++) {
            Map<String, Object> map = new HashMap<String, Object>();
            String key = String.valueOf(getEnum(ary[num].getParam()));
            map.put("param", String.valueOf(ary[num].getParam()));
            map.put("desc", ary[num].getDescribe());
            enumMap.put(key, map);
        }
        return enumMap;
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static List<Map<String, String>> toList() {
        PublicServiceEnum[] ary = PublicServiceEnum.values();
        List list = new ArrayList();
        for (int i = 0; i < ary.length; i++) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("param", String.valueOf(ary[i].getParam()));
            map.put("desc", ary[i].getDescribe());
            list.add(map);
        }
        return list;
    }
}
